package org.benjamin.lending.controller;

import org.benjamin.lending.domain.entity.MemberInfo;
import org.benjamin.lending.domain.form.ResetPassword;
import org.benjamin.lending.service.VerifyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.util.Assert;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

@Controller
@RequestMapping("commons")
public class CommonsController {
	
	@Autowired
	private VerifyService verifyService;

	@RequestMapping(value = "getPasswordVerify")
	public String getPasswordVerify(@RequestParam("vcode") String vcode,ModelMap modelMap){
		MemberInfo memberInfo = this.verifyService.findByMemberInfoVcode(vcode);
		Assert.notNull(memberInfo, "页面错误！");
		ResetPassword resetPassword = new ResetPassword();
		resetPassword.setUserId(memberInfo.getId());
		resetPassword.setUsername(memberInfo.getUsername());
		modelMap.addAttribute("resetPassword",resetPassword);
		return "verify.resetPassword";
	}
}
